package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.OrderInfoTicketInfoMiddle;
import cn.icanci.ladybird.dao.OrderInfoTicketInfoMiddleDao;
import cn.icanci.ladybird.service.OrderInfoTicketInfoMiddleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (OrderInfoTicketInfoMiddle)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:43:38
 */
@Service("orderInfoTicketInfoMiddleService")
public class OrderInfoTicketInfoMiddleServiceImpl implements OrderInfoTicketInfoMiddleService {
    @Resource
    private OrderInfoTicketInfoMiddleDao orderInfoTicketInfoMiddleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderInfoTicketInfoMiddleId 主键
     * @return 实例对象
     */
    @Override
    public OrderInfoTicketInfoMiddle queryById(Long orderInfoTicketInfoMiddleId) {
        return this.orderInfoTicketInfoMiddleDao.queryById(orderInfoTicketInfoMiddleId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<OrderInfoTicketInfoMiddle> queryAllByLimit(int offset, int limit) {
        return this.orderInfoTicketInfoMiddleDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderInfoTicketInfoMiddle 实例对象
     * @return 实例对象
     */
    @Override
    public OrderInfoTicketInfoMiddle insert(OrderInfoTicketInfoMiddle orderInfoTicketInfoMiddle) {
        this.orderInfoTicketInfoMiddleDao.insert(orderInfoTicketInfoMiddle);
        return orderInfoTicketInfoMiddle;
    }

    /**
     * 修改数据
     *
     * @param orderInfoTicketInfoMiddle 实例对象
     * @return 实例对象
     */
    @Override
    public OrderInfoTicketInfoMiddle update(OrderInfoTicketInfoMiddle orderInfoTicketInfoMiddle) {
        this.orderInfoTicketInfoMiddleDao.update(orderInfoTicketInfoMiddle);
        return this.queryById(orderInfoTicketInfoMiddle.getOrderInfoTicketInfoMiddleId());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderInfoTicketInfoMiddleId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long orderInfoTicketInfoMiddleId) {
        return this.orderInfoTicketInfoMiddleDao.deleteById(orderInfoTicketInfoMiddleId) > 0;
    }

    @Override
    public OrderInfoTicketInfoMiddle queryByOrderInfoIdAndTicketId(Long orderInfoId, Long ticketId) {
        return this.orderInfoTicketInfoMiddleDao.queryByOrderInfoIdAndTicketId(orderInfoId, ticketId);
    }
}